package cn.tedu.commpro.controller;

import cn.tedu.commpro.service.GroupECommProSaleService;
import org.ecshop.common.domain.Result;
import org.ecshop.common.domain.productcenter.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GroupECommProSaleController {

    @Autowired
    private GroupECommProSaleService groupECommProSaleService;

    /**
     * @return Result
     * success:上架成功
     * fail:上架失败
     * @author Jane
     * @description 商品上架功能
     * @params Product product
     */
    @RequestMapping(value = "/ecshop/v1/vendors/product/edit_stat_putaway", method = RequestMethod.POST)
    public Result productOnSale(Product product) {

        try {
            groupECommProSaleService.updateProductStatusByProSpuAndProShopId(product.getSpu(), product.getShopId());
            return new Result(true, "", "上架成功", false);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "", "上架失败", false);
        }
    }
}